/*
 * File containing scripts to add and remove choice
 * fields from the CreateClosedEventForm
 * 
 * Author: Chris Casola
 */

/** The current number of choice fields on the create closed event form */
var numChoices = 3;

/**
 * Add another text field to the choice list
 */
function addChoiceController(event) {
	var choiceList = document.getElementById('choices');
	var newChoice = document.createElement('li');
	numChoices++;
	newChoice.innerHTML = "<input type='text' id='choice" + numChoices + "' name='choice3' size='15' />";
	choiceList.appendChild(newChoice);
}

/**
 * Remove the last choice field from the choice list
 */
function removeChoiceController(event) {
	if (numChoices > 3) {
		numChoices--;
		var choiceList = document.getElementById('choices');
		choiceList.removeChild(choiceList.lastChild);
		while (choiceList.lastChild.nodeType != 1) {
			choiceList.removeChild(choiceList.lastChild);
		}
	}
}